/*
 * ========================================================
 * Copyright(c) 2014 杭州偶尔科技-版权所有
 * ========================================================
 * 本软件由杭州偶尔科技所有, 未经书面许可, 任何单位和个人不得以
 * 任何形式复制代码的部分或全部, 并以任何形式传播。
 * 公司网址
 *
 * 			http://www.kkkd.com/
 *
 * ========================================================
 */
package com.simon.mengkou.ui.adapter;

import android.content.Context;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.ouertech.android.agm.lib.base.future.core.AgnettyFuture;
import com.ouertech.android.agm.lib.base.utils.UtilList;
import com.ouertech.android.agm.lib.base.utils.UtilLog;
import com.simon.mengkou.R;
import com.simon.mengkou.data.bean.base.Activity;
import com.simon.mengkou.data.bean.base.Follow;
import com.simon.mengkou.data.bean.base.GoodTopic;
import com.simon.mengkou.data.bean.base.Topic;
import com.simon.mengkou.data.bean.base.User;
import com.simon.mengkou.data.enums.EEventId;
import com.simon.mengkou.system.global.OuerApplication;
import com.simon.mengkou.system.global.OuerDispatcher;
import com.simon.mengkou.ui.fragment.HomeFragment;
import com.simon.mengkou.ui.view.AvatarSimpleDraweeView;
import com.simon.mengkou.ui.view.SmallFollowButton;
import com.simon.mengkou.ui.view.TinyFollowButton;
import com.umeng.analytics.MobclickAgent;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * @author : Zhenshui.Xia
 * @since : 2016/3/23.
 * desc    : 热门帖子适配器
 */
public class HotTopicAdapter extends AbsAdapter<Follow> {
    public HotTopicAdapter(Context context) {
        super(context);
    }


    @Override
    public View getView(int position, View convertView, ViewGroup arg2) {
        final Holder holder;
        if (null == convertView) {
            convertView = mInflater.inflate(R.layout.layout_hot_topic_item, null);
            holder = new Holder();
            convertView.setTag(holder);
            ButterKnife.bind(holder, convertView);
        } else {
            holder = (Holder) convertView.getTag();
        }


        final Follow data = getItem(position);

        holder.mLlInfoRoot.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MobclickAgent.onEvent(mContext, EEventId.HOME_RECOMMEND_FOLLOW);
                OuerDispatcher.presentShareOrderDetailActivity(mContext, data.getId());
            }
        });

        User user = data.getUser();
        //头像
        holder.mSdvAvatar.loadAvatar(user.getAvatarUrl(), user.getLevel());

        //昵称
        holder.mTvName.setText(user.getNick());

        return convertView;
    }


    /**
     * @author zhenshui.xia
     */
    class Holder {
        //
        @Bind(R.id.hot_topic_id_info_root)
        LinearLayout mLlInfoRoot;
        //头像
        @Bind(R.id.hot_topic_id_avatar)
        AvatarSimpleDraweeView mSdvAvatar;
        //昵称
        @Bind(R.id.hot_topic_id_name)
        TextView mTvName;
    }
}
